<template>
    <div>
        <van-sticky>
        <van-nav-bar title="搜索结果" left-text="返回" left-arrow @click-left="onClickLeft" />
        </van-sticky>
        <h1>搜索结果</h1>
        <ul>
            <li v-for="item in list" :key="item.id">{{item.title}}</li>
        </ul>
    </div>
</template>

<script>
export default {
    data() {
        return {
            list:[],
        };
    },
    mounted() {
        this.$axios
        .get("/list.json").then((res)=>{
            this.list = res.data.result.filter((item)=>{
                // 查询数据里的关键字
                return item.title.includes(this.$route.query.val)
            })
        })
    },
    methods: {
        onClickLeft(){
            this.$router.go(-1)
        }
    },
};
</script>

<style lang='scss'>

</style>
